package servletdemo;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("处理Get()请求...");
		PrintWriter out = response.getWriter();
		//指定输出的文件类型
		response.setContentType("text/html;charset=utf-8");
		out.println("<strong>Get Hello Servlet!</strong><br>");
		
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		System.out.println("处理Post()请求...");
		PrintWriter out = response.getWriter();
		//指定输出的文件类型
		response.setContentType("text/html;charset=utf-8");
		out.println("<strong>Post Hello Servlet!</strong><br>");
	}
	
}
